package ia1011.zanzibar.rules;

import java.util.*;

/**
 * The class represents an element of a regular expression which is the 
 * disjunction of two or more regular expressions.
 * 
 * @author Alessandro Perrino (creator)
 * @author <br> Bastianelli E. emanuele.bastianelli@gmail.com (modifier)
 * @author <br> Caponi E. emiliano.caponi@gmail.com (modifier)
 * @author <br> Castellucci G. castellucci.giuseppe@gmail.com (modifier)
 * @author <br> Rossi A. berardino.viola@gmail.com (modifier)
 * 
 *
 */

public class AltElem extends RegExElem {
	// The set of alternative regular expressions
	Vector elements;
	
	/**
	 * create new AltElem 
	 */
	public AltElem() {
		elements = new Vector();
	}
	
	/**
	 * add a regex to AltElem
	 * @param regex
	 */
	public void addElement(FSRegEx regex) {
		elements.addElement(regex);
	}
	
	/**
	 * 
	 * @return all the elements of AltElem
	 */
	public Vector getElements() {
		return elements;
	}
	
	/**
	 * Prints a simple representation of the elements. 
	 */
	public void display() {
		Iterator iter = elements.iterator();
		while (iter.hasNext()) {
			RegExElem currentElem = (RegExElem)iter.next();
			currentElem.display();
			if (iter.hasNext())
				System.out.println("|");
		}
	}
}
